package com.eatme.core.set;

import com.eatme.core.array.ArrayGenerator;

// 有序集合 基于搜索树的实现
//无序集合 基于哈希表的实现
//多重集合
public interface Set<E> {

    void add(E e);

    void remove(E e);

    boolean contains(E e);

    int getSize();

    boolean isEmpty();

    private static double testSet(Set<Integer> set, Integer[] arr) {

        long startTime = System.nanoTime();
        System.out.println("Total words: "+arr.length);
        for (int i = 0;i<arr.length;i++)
            set.add(arr[i]);
        System.out.println("Total different words: " +set.getSize());
        long endTime = System.nanoTime();
        return  (endTime-startTime)/ 1000000.0;
    }

    public static void main(String[] args) {
        int n = 100000;
        Integer[] arr = ArrayGenerator.generateRandomArray(n, n);
        Set<Integer> set = new BSTSet<>();
        Set<Integer> set1 = new LinkedListSet<>();
        double msTime = testSet(set,arr);
        System.out.println("BSTSet: " +msTime+" ms");
        System.out.println();
        double msTime1 =testSet(set1,arr);
        System.out.println("LinkedListSet: " +msTime1+" ms");



    }
}
